<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<title>FCRE2.1--考试中...</title>
<style>
.ibox-content{padding:0px;}
.ibox-content .bs-bars{margin:0px;}
.fixed-table-container{margin-left:30px;}
.ibox-title{color:#de5f14;background-color: #cff7d4;}
</style>
<body class="gray-bg">
<div class="row  border-bottom white-bg">
	<div class="border-bottom" style="background: #FFC107;padding: 0px 10px 0px 20px;">
            <nav class="navbar" role="navigation"
                 style="margin-bottom: 0">
                <div class="navbar-header">
					<ul class="nav navbar-top-links welcome-message">
                    <li>
                        <span class="text-muted"></span>
                    </li>
                    <li><a class="btn btn-primary" href="#"><i class="fa fa-edit fa-lg"></i>考试任务</a></li>
                </ul>
                </div>
                <ul class="nav navbar-top-links navbar-right welcome-message">
                    <li>
                        <span class="text-muted"></span>
                    </li>
                    <li>
                    <th:block th:if="${not #strings.contains(perms, 'exam:exarrange:kcmgr')}">
                    <a class="btn btn-danger" href="login/kdlogout" style="width: 103px;"><i class="fa fa-sign-out fa-lg"></i>退出</a>
                    </th:block>
                    <th:block th:if="${#strings.contains(perms, 'exam:exarrange:kcmgr')}">
                    <a class="btn btn-danger" href="/login/kdlogout" style="width: 103px;"><i class="fa fa-sign-out fa-lg"></i>退出</a>
                    </th:block>
                    </li>
                </ul>
            </nav>
        </div>
		<div class="col-sm-12">
			<div class="ibox-content">
			<table id="bootstrap-table-exam" data-mobile-responsive="true"></table>			
			</div>
		</div>
</div>

    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
var now0=Date.parse([[${now0}]].replace(/-/g,"/"));

$(function() {	
	var optionsexam = {
			id:"bootstrap-table-exam",
			[# th:unless="${#strings.contains(perms, 'exam:exarrange:kcmgr')}"]
			url : ctx + "exam/exarrange/myks",
			[/]
     		[# th:if="${#strings.contains(perms, 'exam:exarrange:kcmgr')}"]	
     		url : ctx + "exam/exarrange/mylist",
     		[/]
			//modalName: "我的考试2",
			striped : true,
			search : false,
			showSearch : false,
			showRefresh : false,
			showColumns : false,
			showToggle : false,
			showExport : false,
			sortOrder : "desc",
			sortName : "starttime",
			columns : [ {
				[# th:unless="${#strings.contains(perms, 'exam:exarrange:kcmgr')}"]
				field : 'paperdef.name',
				[/]
		     	[# th:if="${#strings.contains(perms, 'exam:exarrange:kcmgr')}"]
		     	field : 'name',
				[/]
				title : '考试名称'
			},
			{
				[# th:unless="${#strings.contains(perms, 'exam:exarrange:kcmgr')}"]
				field : 'paperdef.totalScore', 
				[/]
			     	[# th:if="${#strings.contains(perms, 'exam:exarrange:kcmgr')}"]
			     	field : 'totalScore',
					[/]
				title : '卷面总分'
			},
			{
				[# th:unless="${#strings.contains(perms, 'exam:exarrange:kcmgr')}"]
				field : 'paperdef.remark',
				[/]
			     	[# th:if="${#strings.contains(perms, 'exam:exarrange:kcmgr')}"]
			     	field : 'remark',
					[/]
				title : '说明'
			},
			{
				field : 'starttime', 
				title : '开始时间'
			},
			{
				field : 'endtime', 
				title : '结束时间'
			},
			{
				field : 'duration', 
				title : '考试时长'
			},
			{
	            align: 'center',
	            title:'操作',
	            formatter: function(value, row, index) {
	            	var actions = [];
	            	[# th:unless="${#strings.contains(perms, 'exam:exarrange:kcmgr')}"]
	            	var starttime=Date.parse(row.starttime.replace(/-/g,"/"));
	            	var endtime=Date.parse(row.endtime.replace(/-/g,"/"));
	            		if(starttime>now0)
		            		actions.push('<a class="btn btn-warning " href="#" ><i class="fa fa-edit"></i> 考试未开始</a> ');
		            	else if((endtime>=now0)){ 
		            		if(row.status==8)
		            			actions.push('<a class="btn btn-danger " href="#"><i class="fa fa-minus-circle"></i> 已交卷</a> ');
		            		else
		            		actions.push('<a class="btn btn-info " href="#" onclick="joinexam(\'' +row.ksid+'\')"><i class="fa fa-edit"></i> 进入考试</a> ');
		            	}
                        else actions.push('<a class="btn btn-danger " href="#" ><i class="fa fa-close"></i> 考试已结束</a> ');
	            		[/]
	            		[# th:if="${#strings.contains(perms, 'exam:exarrange:kcmgr')}"]	
	            	actions.push('<a class="btn btn-info " href="#" onclick="gokc(\'' +row.id+'\')"><i class="fa fa-edit"></i> 进入考场</a>');
	            		[/]
					return actions.join('');
	            }
	            
	        } ]
		};
		$.table.init(optionsexam);
});
function joinexam(id){
	$.modal.loading("正在加载数据，请稍后...");
	$.ajax({
		type: "POST",
		url: ctx + "exam/exarrange/check",
		data: {"id":id},
		dataType: "json",
		success: function(ret){
			$.modal.closeLoading();
			if(ret.code == 0){
				top.location.href=ctx+"exam/exarrange/joinexam/"+id;
			}else{
				$.modal.alertWarning(ret.msg);
			}
		},
		error:function(ret){
			$.modal.closeLoading();
			$.modal.alertWarning(ret.msg);
		}
	});	
}
function gokc(id){
	top.location.href=ctx+"exam/exarrange/kcmgr/"+id;
}
</script>
</body>
</html>
